//
//  TestView.m
//  Runner
//
//  Created by yeqingyu on 2019/7/24.
//  Copyright © 2019 The Chromium Authors. All rights reserved.
//

#import "TestViewManager.h"
#import "TestViewController.h"
@interface TestViewManager ()
@property (nonatomic, assign) int64_t viewId;
/**页面frame*/
@property (nonatomic, assign) CGRect frame;
/**参数*/
@property(nonatomic,strong) id  args;
@property(nonatomic,strong)FlutterMethodChannel *channel;
@property(nonatomic,strong)id messenger;
@end
@implementation TestViewManager
- (instancetype)initWithWithFrame:(CGRect)frame
                   viewIdentifier:(int64_t)viewId
                        arguments:(id _Nullable)args
                  binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger{
    self = [super init];
    if (self) {
        self.frame = frame;
        self.viewId = viewId;
        self.args = args;
        self.messenger = messenger;
    }
    return self;
}

// MARK: 初始化channel
- (void)initMethodChannel{
    NSString* channelName = [NSString stringWithFormat:@"plugins/activity_indicator_%lld", _viewId];
    _channel = [FlutterMethodChannel methodChannelWithName:channelName binaryMessenger:_messenger];
    __weak __typeof__(self) weakSelf = self;
    [_channel setMethodCallHandler:^(FlutterMethodCall *  call, FlutterResult  result) {//处理事件
        if ([[call method] isEqualToString:@"xxx"]) {
            
        }
    }];
}
-(UIView *)view{
//    [self initMethodChannel];
    TestViewController *testVc = [[TestViewController alloc]init];
    testVc.view.frame = self.frame;
    return testVc.view;
    
}

@end
